package com.cheung.leetcode.str;

import org.junit.jupiter.api.Test;

/**
 * @BelongsProject : java-leetcode
 * @BelongsPackage : com.cheung.leetcode.str
 * @Author :  cheungming
 * @CreateTime : 2024-05-09 09:22:32
 * @Description : 重复子串
 * @Version : 1.0
 */
public class Code459Test {


    public boolean repeatedSubstringPattern(String s) {
        return (s + s).indexOf(s, 1) != s.length();
    }


    @Test
    public void test1() {
        String s = "abab";
        assert repeatedSubstringPattern(s);
    }


    @Test
    public void test2() {
        String s = "aba";
        assert !repeatedSubstringPattern(s);
    }

    @Test
    public void test3() {
        String s = "abcabcabcabc";
        assert repeatedSubstringPattern(s);
    }

    @Test
    public void test4() {
        System.out.println("abaaba".indexOf("aba", 1));
        System.out.println("abababab".indexOf("abab", 1));
    }
}
